{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "a46cdfbb",
   "metadata": {},
   "outputs": [],
   "source": [
    "#!pip3 install langchain"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "d1af0134",
   "metadata": {},
   "source": [
    "## Import packages"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "7fd542dd",
   "metadata": {},
   "outputs": [],
   "source": [
    "from dotenv import load_dotenv\n",
    "from langchain.embeddings import OpenAIEmbeddings\n",
    "from langchain.vectorstores import ElasticsearchStore\n",
    "from langchain.text_splitter import CharacterTextSplitter\n",
    "from urllib.request import urlopen\n",
    "import os, json\n",
    "\n",
    "load_dotenv()\n",
    " \n",
    "openai_api_key=os.getenv('OPENAI_API_KEY')\n",
    "elastic_user=os.getenv('ES_USER')\n",
    "elastic_password=os.getenv('ES_PASSWORD')\n",
    "elastic_endpoint=os.getenv(\"ES_ENDPOINT\")\n",
    "elastic_index_name='elasticsearch-store'"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "1fcd1757",
   "metadata": {},
   "source": [
    "# Add documents"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "cd4155d7",
   "metadata": {},
   "source": [
    "## Let's read the sample dataset and deserialize the document."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "id": "aed6aa32",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Successfully loaded 15 documents\n"
     ]
    }
   ],
   "source": [
    "with open('workplace-docs.json') as f:\n",
    "   workplace_docs = json.load(f)\n",
    " \n",
    "print(f\"Successfully loaded {len(workplace_docs)} documents\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "a7e1dd83",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Created a chunk of size 245, which is longer than the specified 50\n",
      "Created a chunk of size 288, which is longer than the specified 50\n",
      "Created a chunk of size 204, which is longer than the specified 50\n",
      "Created a chunk of size 281, which is longer than the specified 50\n",
      "Created a chunk of size 249, which is longer than the specified 50\n",
      "Created a chunk of size 285, which is longer than the specified 50\n",
      "Created a chunk of size 298, which is longer than the specified 50\n",
      "Created a chunk of size 270, which is longer than the specified 50\n",
      "Created a chunk of size 224, which is longer than the specified 50\n",
      "Created a chunk of size 288, which is longer than the specified 50\n",
      "Created a chunk of size 260, which is longer than the specified 50\n",
      "Created a chunk of size 199, which is longer than the specified 50\n",
      "Created a chunk of size 290, which is longer than the specified 50\n",
      "Created a chunk of size 251, which is longer than the specified 50\n",
      "Created a chunk of size 195, which is longer than the specified 50\n",
      "Created a chunk of size 242, which is longer than the specified 50\n",
      "Created a chunk of size 275, which is longer than the specified 50\n",
      "Created a chunk of size 277, which is longer than the specified 50\n",
      "Created a chunk of size 284, which is longer than the specified 50\n",
      "Created a chunk of size 285, which is longer than the specified 50\n",
      "Created a chunk of size 324, which is longer than the specified 50\n",
      "Created a chunk of size 328, which is longer than the specified 50\n",
      "Created a chunk of size 280, which is longer than the specified 50\n",
      "Created a chunk of size 123, which is longer than the specified 50\n",
      "Created a chunk of size 221, which is longer than the specified 50\n",
      "Created a chunk of size 330, which is longer than the specified 50\n",
      "Created a chunk of size 292, which is longer than the specified 50\n",
      "Created a chunk of size 240, which is longer than the specified 50\n",
      "Created a chunk of size 232, which is longer than the specified 50\n",
      "Created a chunk of size 324, which is longer than the specified 50\n",
      "Created a chunk of size 167, which is longer than the specified 50\n",
      "Created a chunk of size 181, which is longer than the specified 50\n",
      "Created a chunk of size 353, which is longer than the specified 50\n",
      "Created a chunk of size 471, which is longer than the specified 50\n",
      "Created a chunk of size 400, which is longer than the specified 50\n",
      "Created a chunk of size 607, which is longer than the specified 50\n",
      "Created a chunk of size 440, which is longer than the specified 50\n",
      "Created a chunk of size 788, which is longer than the specified 50\n",
      "Created a chunk of size 547, which is longer than the specified 50\n",
      "Created a chunk of size 67, which is longer than the specified 50\n",
      "Created a chunk of size 635, which is longer than the specified 50\n",
      "Created a chunk of size 440, which is longer than the specified 50\n",
      "Created a chunk of size 464, which is longer than the specified 50\n",
      "Created a chunk of size 372, which is longer than the specified 50\n",
      "Created a chunk of size 866, which is longer than the specified 50\n",
      "Created a chunk of size 111, which is longer than the specified 50\n",
      "Created a chunk of size 361, which is longer than the specified 50\n",
      "Created a chunk of size 110, which is longer than the specified 50\n",
      "Created a chunk of size 471, which is longer than the specified 50\n",
      "Created a chunk of size 288, which is longer than the specified 50\n",
      "Created a chunk of size 150, which is longer than the specified 50\n",
      "Created a chunk of size 62, which is longer than the specified 50\n",
      "Created a chunk of size 619, which is longer than the specified 50\n",
      "Created a chunk of size 257, which is longer than the specified 50\n",
      "Created a chunk of size 310, which is longer than the specified 50\n",
      "Created a chunk of size 310, which is longer than the specified 50\n",
      "Created a chunk of size 282, which is longer than the specified 50\n",
      "Created a chunk of size 230, which is longer than the specified 50\n",
      "Created a chunk of size 213, which is longer than the specified 50\n",
      "Created a chunk of size 395, which is longer than the specified 50\n",
      "Created a chunk of size 270, which is longer than the specified 50\n",
      "Created a chunk of size 224, which is longer than the specified 50\n",
      "Created a chunk of size 292, which is longer than the specified 50\n",
      "Created a chunk of size 231, which is longer than the specified 50\n",
      "Created a chunk of size 153, which is longer than the specified 50\n",
      "Created a chunk of size 277, which is longer than the specified 50\n",
      "Created a chunk of size 171, which is longer than the specified 50\n",
      "Created a chunk of size 106, which is longer than the specified 50\n",
      "Created a chunk of size 253, which is longer than the specified 50\n",
      "Created a chunk of size 140, which is longer than the specified 50\n",
      "Created a chunk of size 323, which is longer than the specified 50\n",
      "Created a chunk of size 95, which is longer than the specified 50\n",
      "Created a chunk of size 201, which is longer than the specified 50\n",
      "Created a chunk of size 174, which is longer than the specified 50\n",
      "Created a chunk of size 232, which is longer than the specified 50\n",
      "Created a chunk of size 238, which is longer than the specified 50\n",
      "Created a chunk of size 193, which is longer than the specified 50\n",
      "Created a chunk of size 305, which is longer than the specified 50\n",
      "Created a chunk of size 1120, which is longer than the specified 50\n",
      "Created a chunk of size 397, which is longer than the specified 50\n",
      "Created a chunk of size 320, which is longer than the specified 50\n",
      "Created a chunk of size 567, which is longer than the specified 50\n",
      "Created a chunk of size 300, which is longer than the specified 50\n",
      "Created a chunk of size 217, which is longer than the specified 50\n",
      "Created a chunk of size 271, which is longer than the specified 50\n",
      "Created a chunk of size 264, which is longer than the specified 50\n",
      "Created a chunk of size 340, which is longer than the specified 50\n",
      "Created a chunk of size 383, which is longer than the specified 50\n",
      "Created a chunk of size 243, which is longer than the specified 50\n",
      "Created a chunk of size 344, which is longer than the specified 50\n",
      "Created a chunk of size 225, which is longer than the specified 50\n",
      "Created a chunk of size 208, which is longer than the specified 50\n",
      "Created a chunk of size 420, which is longer than the specified 50\n",
      "Created a chunk of size 89, which is longer than the specified 50\n",
      "Created a chunk of size 94, which is longer than the specified 50\n",
      "Created a chunk of size 299, which is longer than the specified 50\n",
      "Created a chunk of size 310, which is longer than the specified 50\n"
     ]
    }
   ],
   "source": [
    "metadata = []\n",
    "content = []\n",
    "\n",
    "for doc in workplace_docs:\n",
    "  content.append(doc[\"content\"])\n",
    "  metadata.append({\n",
    "      \"name\": doc[\"name\"],\n",
    "      \"summary\": doc[\"summary\"],\n",
    "      \"rolePermissions\":doc[\"rolePermissions\"]\n",
    "  })\n",
    "\n",
    "text_splitter = CharacterTextSplitter(chunk_size=50, chunk_overlap=0)\n",
    "docs = text_splitter.create_documents(content, metadatas=metadata)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04af8350",
   "metadata": {},
   "outputs": [],
   "source": [
    "docs"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "26b224ed",
   "metadata": {},
   "outputs": [],
   "source": [
    "from elasticsearch import Elasticsearch\n",
    "\n",
    "embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)\n",
    " \n",
    "url = f\"https://{elastic_user}:{elastic_password}@{elastic_endpoint}:9200\"\n",
    "connection = Elasticsearch(url, ca_certs = \"./http_ca.crt\", verify_certs = True)\n",
    "\n",
    " \n",
    "es = ElasticsearchStore.from_documents( \n",
    "                            docs,\n",
    "                            embedding = embeddings, \n",
    "                            es_url = url, \n",
    "                            es_connection = connection,\n",
    "                            index_name = elastic_index_name, \n",
    "                            es_user = elastic_user,\n",
    "                            es_password = elastic_password)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "827ca31c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<langchain.vectorstores.elasticsearch.ElasticsearchStore at 0x1117eded0>"
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "es"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "id": "247482c4",
   "metadata": {},
   "outputs": [],
   "source": [
    "def showResults(output):\n",
    "  print(\"Total results: \", len(output))\n",
    "  for index in range(len(output)):\n",
    "    print(output[index])"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "be766397",
   "metadata": {},
   "source": [
    "# Similarity / Vector Search (Approximate KNN Search) - ApproxRetrievalStrategy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "id": "d5189c9b",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Total results:  4\n",
      "page_content='The purpose of this full-time work-from-home policy is to provide guidelines and support for employees to conduct their work remotely, ensuring the continuity and productivity of business operations during the COVID-19 pandemic and beyond.\\nScope' metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}\n",
      "page_content='This work-from-home policy will be reviewed periodically and updated as necessary, taking into account changes in public health guidance, business needs, and employee feedback.\\nQuestions and Concerns' metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}\n",
      "page_content='This policy applies to all employees who are eligible for remote work as determined by their role and responsibilities. It is designed to allow employees to work from home full time while maintaining the same level of performance and collaboration as they would in the office.\\nEligibility' metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}\n",
      "page_content='The company encourages employees to prioritize their health and well-being while working from home. This includes taking regular breaks, maintaining a work-life balance, and seeking support from supervisors and colleagues when needed.\\nPolicy Review and Updates' metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}\n"
     ]
    }
   ],
   "source": [
    "query = \"work from home policy\"\n",
    "result = es.similarity_search(query=query)\n",
    "\n",
    "showResults(result)"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "95983ac5",
   "metadata": {},
   "source": [
    "# Hybrid Search (Approximate KNN + Keyword Search) - ApproxRetrievalStrategy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "id": "a7b25d0d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='This work-from-home policy will be reviewed periodically and updated as necessary, taking into account changes in public health guidance, business needs, and employee feedback.\\nQuestions and Concerns', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}),\n",
       " Document(page_content='The purpose of this full-time work-from-home policy is to provide guidelines and support for employees to conduct their work remotely, ensuring the continuity and productivity of business operations during the COVID-19 pandemic and beyond.\\nScope', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}),\n",
       " Document(page_content='The company encourages employees to prioritize their health and well-being while working from home. This includes taking regular breaks, maintaining a work-life balance, and seeking support from supervisors and colleagues when needed.\\nPolicy Review and Updates', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}),\n",
       " Document(page_content='This policy applies to all employees who are eligible for remote work as determined by their role and responsibilities. It is designed to allow employees to work from home full time while maintaining the same level of performance and collaboration as they would in the office.\\nEligibility', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']})]"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)\n",
    "\n",
    "\n",
    "es = ElasticsearchStore(\n",
    "    es_url = url,\n",
    "    es_connection = connection,\n",
    "    es_user=elastic_user,\n",
    "    es_password=elastic_password,\n",
    "    embedding=embeddings,\n",
    "    index_name=elastic_index_name,\n",
    "    strategy=ElasticsearchStore.ApproxRetrievalStrategy(\n",
    "        hybrid=True\n",
    "    )\n",
    ")\n",
    "\n",
    "es.similarity_search(\"work from home policy\")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "36eb7ac6",
   "metadata": {},
   "source": [
    "# Exact KNN Search (Brute Force) - ExactRetrievalStrategy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "9d618994",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='The purpose of this full-time work-from-home policy is to provide guidelines and support for employees to conduct their work remotely, ensuring the continuity and productivity of business operations during the COVID-19 pandemic and beyond.\\nScope', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}),\n",
       " Document(page_content='This work-from-home policy will be reviewed periodically and updated as necessary, taking into account changes in public health guidance, business needs, and employee feedback.\\nQuestions and Concerns', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}),\n",
       " Document(page_content='This policy applies to all employees who are eligible for remote work as determined by their role and responsibilities. It is designed to allow employees to work from home full time while maintaining the same level of performance and collaboration as they would in the office.\\nEligibility', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']}),\n",
       " Document(page_content='The company encourages employees to prioritize their health and well-being while working from home. This includes taking regular breaks, maintaining a work-life balance, and seeking support from supervisors and colleagues when needed.\\nPolicy Review and Updates', metadata={'name': 'Work From Home Policy', 'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager']})]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)\n",
    "\n",
    "\n",
    "es = ElasticsearchStore(\n",
    "    es_url = url,\n",
    "    es_connection = connection,\n",
    "    es_user=elastic_user,\n",
    "    es_password=elastic_password,\n",
    "    embedding=embeddings,\n",
    "    index_name=elastic_index_name,\n",
    "    strategy=ElasticsearchStore.ExactRetrievalStrategy()\n",
    ")\n",
    "\n",
    "es.similarity_search(\"work from home policy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "10a69146",
   "metadata": {},
   "outputs": [],
   "source": [
    "embeddings = OpenAIEmbeddings(openai_api_key=openai_api_key)\n",
    "\n",
    "es = ElasticsearchStore.from_documents(\n",
    "    docs,\n",
    "    es_url = url,\n",
    "    es_connection = connection,\n",
    "    es_user=elastic_user,\n",
    "    es_password=elastic_password,\n",
    "    index_name=elastic_index_name+\"-\"+\"elser\",\n",
    "    strategy=ElasticsearchStore.SparseVectorRetrievalStrategy()\n",
    ")\n"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "6d013ebc-d71c-49d3-afbc-577d5326961e",
   "metadata": {},
   "source": [
    "# Index / Search Documents using ELSER - SparseVectorRetrievalStrategy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "id": "a46ab7ce",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<langchain.vectorstores.elasticsearch.ElasticsearchStore at 0x1371121d0>"
      ]
     },
     "execution_count": 29,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "es"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "id": "1b0cd571-3342-4ce9-855d-ae222a7f3cfc",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[Document(page_content='The purpose of this full-time work-from-home policy is to provide guidelines and support for employees to conduct their work remotely, ensuring the continuity and productivity of business operations during the COVID-19 pandemic and beyond.\\nScope', metadata={'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager'], 'name': 'Work From Home Policy'}),\n",
       " Document(page_content='This work-from-home policy will be reviewed periodically and updated as necessary, taking into account changes in public health guidance, business needs, and employee feedback.\\nQuestions and Concerns', metadata={'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager'], 'name': 'Work From Home Policy'}),\n",
       " Document(page_content=\"Employees must adhere to the company's confidentiality and data security policies while working from home. This includes safeguarding sensitive information, securing personal devices and internet connections, and reporting any security breaches to the IT department.\\nHealth and Well-being\", metadata={'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager'], 'name': 'Work From Home Policy'}),\n",
       " Document(page_content='This policy applies to all employees who are eligible for remote work as determined by their role and responsibilities. It is designed to allow employees to work from home full time while maintaining the same level of performance and collaboration as they would in the office.\\nEligibility', metadata={'summary': 'This policy outlines the guidelines for full-time remote work, including eligibility, equipment and resources, workspace requirements, communication expectations, performance expectations, time tracking and overtime, confidentiality and data security, health and well-being, and policy reviews and updates. Employees are encouraged to direct any questions or concerns', 'rolePermissions': ['demo', 'manager'], 'name': 'Work From Home Policy'})]"
      ]
     },
     "execution_count": 30,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "es.similarity_search(\"work from home policy\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "85c2b936-c8da-4e0e-9d42-e3e95e0febfc",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python",
   "language": "python",
   "name": "py"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
